package top.lyjwn.todo.aop.config;

import com.alibaba.fastjson2.JSONObject;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.RedisTemplate;
import top.lyjwn.todo.common.config.RedisConfig;


@Configuration
public class TokenRedisConfig extends RedisConfig {


//
//    private  Environment environment;
//
//    @Override
//    public void setEnvironment(Environment environment) {
//        this.environment = environment;
//    }

    @Bean(name = "tokenRedisTemplate")
    public RedisTemplate<String, JSONObject> redisTemplate() {

        String redis_index = this.environment.getProperty("lyjwn.token.redis_index", "0");
        return getRedisTemplate(JSONObject.class, redis_index.isEmpty() ? 0 : Integer.parseInt(redis_index));
    }

}